module.exports = agent => {
    console.log('env', agent.config.env);
    //是否格式化数据库
    agent.beforeStart(async function () {
        if (!agent.model)
            return;


        await agent.model.sync();

        //初始化
        const init = await agent.model.Config.get('init', false);
        if (!init) {
            await Promise.all([
                agent.model.Type.findOrCreate({where: {name: '默认类型'}}).spread(() => {
                    return Promise.resolve();
                }),
                agent.model.User.create({username: '123', password: '123'}),
                agent.model.Config.set('active_minutes', 30),// 判断是不是活跃主播的直播长度,分钟
                agent.model.Config.set('room_queue', 10),// 处理直播间信息的线程并行数量
                agent.model.Platform.bulkCreate([
                    {name: '网易CC', tag: 'cc'},
                    {name: '熊猫TV', tag: 'panda'},
                    {name: '触手TV', tag: 'chushou'},
                    {name: '战旗TV', tag: 'zhanqi'},
                    {name: '火猫TV', tag: 'huomao'},
                    {name: '斗鱼TV', tag: 'douyu'},
                    {name: '虎牙TV', tag: 'huya'},
                    {name: '全民直播', tag: 'quanmin'},
                    {name: '龙珠直播', tag: 'longzhu'},
                    {name: '企鹅电竞', tag: 'egame'},
                    {name: '哔哩哔哩', tag: 'bilibili'},
                ]),
                agent.model.Config.set('init', true),
            ]);
        } else {
        }

    });
};